<?
$page_title="Login Authentication.. ";
$mindex=1;
?>
<?include("includes/header.php") ?>

<div class="bodycontent">
<br/>
<?
if($_POST){
foreach($_POST as $key => $value) { $arr_data[$key]=$value;}
foreach($arr_data as $key => $value) { $arr_data[$key]=addslashes($value); }
}	
if($_POST && $_POST["newuser"]==0){
	
	$retInfo=validateUser($arr_data["username"],$arr_data["password"]);
	if($retInfo==1){
	 $msg="Invalid Username. Please check";
	}
	else if($retInfo==2){
	 $msg="Invalid Password";
	}else{
		
		$_SESSION["user_id"]=$retInfo["user_id"];
		$_SESSION["username"]=$retInfo["user_name"];
		
		header("location:timesheet.php");
	
	}

}else if($_POST && $_POST["newuser"]==1){

if($_POST["user_name"]!=""){

$query_id=insert_qry("dev_user_mast",$arr_data);

}



}

?>
<form method="post" >
<div class="errorBox"> <?=$msg?></div>
<div class="loginBox">
<div class="frmrow">
	<span class="frmlabel">Username :</span>
	<input type="text" name="username" id="username" class="loginInput"/>

	 <br/>
</div>

<div class="frmrow">
	<span class="frmlabel">Password :</span>
	<input type="password" name="password" id="password" class="loginInput"/> <input type="submit" value="Login..." class="button" />
	
	 <br/>
</div>
</div>
 <input type="hidden" name="newuser" value="0" />
</form>

<hr/>

<div class="page_title">New User Sign up</div>
<form method="post">
<div class="loginBox">
<div class="frmrow">
	<span class="frmlabel">First Name :</span>
	<input type="text" name="user_firstname" id="user_firstname" class="loginInput"/>

	 <br/>
</div>
<div class="frmrow">
	<span class="frmlabel">Email:</span>
	<input type="text" name="user_email " id="user_email " class="loginInput"/>

	 <br/>
</div>

<div class="frmrow">
	<span class="frmlabel">Username :</span>
	<input type="text" name="user_name" id="user_name" class="loginInput"/>

	 <br/>
</div>

<div class="frmrow">
	<span class="frmlabel">Password :</span>
	<input type="password" name="password" id="password" class="loginInput"/> 
	
	 <br/>
	 <input type="hidden" name="newuser" value="1" />
</div>
<div class="frmrow" style="margin-left:300px;">
<input type="submit" value="Quick Signup" class="button" />
</div>

</div>
</form>

</div>
<?include("includes/footer.php") ?>